import Query from './Query'
import Mutation from './Mutation'
import Subscription from './Subscription'

export default {
    Query,
    Mutation,
    Subscription,
    User: {
        following: (parent, args, { prisma }) => {
            return prisma.user({ id: parent.id }).following();
        },
        followers: (parent, args, { prisma }) => {
            return prisma.user({ id: parent.id }).followers();
        },
        profile: (parent, args, { prisma }) => {
            return prisma.user({ id: parent.id }).profile();
        },
        categories: (parent, args, { prisma }) => {
            return prisma.user({ id: parent.id }).categories();
        },
        posts: (parent, args, { prisma }) => {
            return prisma.user({ id: parent.id }).posts();
        },
    },
    Profile:{
        user: (parent, args, { prisma }) => {
            return prisma.profile({ id: parent.id }).user();
        },
    },
    Post:{
        categories: (parent, args, { prisma }) => {
            return prisma.post({ id: parent.id }).categories();
        },
        author: (parent, args, { prisma }) => {
            return prisma.post({ id: parent.id }).author();
        }
    },
    Category:{
        author: (parent, args, { prisma }) => {
            return prisma.category({ id: parent.id }).author();
        },
        posts: (parent, args, { prisma }) => {
            return prisma.category({ id: parent.id }).posts();
        },
    },
    PostConnection:{
        aggregate:(parent, args, { prisma }) => {
            return prisma.postsConnection(args).aggregate();
            // return prisma.postsConnection().aggregate().count();
        }
    }
}